#region <!--##session LoginWholeClass##-->

		/*<!--##
		codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
		##-->*/
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using EXtremecode.PresentationLayer;	
using EXtremecode.Common.UI;
using EXtremecode.Common;
namespace <!--##=RepositoryManager.Instance.Repository.ProjectName##-->
{
		/*<!--##
		 codeGeneratorVariable_DisplayCode.Append(LoginCodeBehind() + Environment.NewLine);
		##-->*/
}
	
<!--##/session##-->
#endregion

#region <!--##session LoginCodeBehind##-->
		public partial class Login : System.Web.UI.Page
				   {
					   protected void Page_Load(object sender, EventArgs e)
					   {
                           if (BOCommon.GetUserLogin() is DummyUserLogin)
                           {
                               bool isPersistent = true;
                               IUser user = new DummyUser();
                               UserProfile.Instance.User = user;
                               FormsAuthenticationTicket ticket =
                                   new FormsAuthenticationTicket(user.UserId, isPersistent, 20);

                               // Encrypt the ticket.
                               string encTicket = FormsAuthentication.Encrypt(ticket);

                               // Create the cookie.
                               Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

                               // Redirect back to original URL.
                               Response.Redirect(FormsAuthentication.GetRedirectUrl(user.UserId, isPersistent));

                           }

                           Page.Form.DefaultButton = btnLogin.UniqueID;
                           if (!IsPostBack)
                            {
                                if (Request.QueryString["unauthorized"] == "true")
                                {
                                    lblErrorMessage.Text = ResourceProvider.GetGeneralResourceString("Message_UnauthorizedUser");
                                }
                            }
					   }
					   protected void btnLogin_Click(object sender, EventArgs e)
					   {
						   bool isPersistent = true;
						   IUserLogin userLogin = BOCommon.GetUserLogin();
            
						   //---testing encrypting functionality.
						   //string str=DataEncryptor.Instance.GetEncryptedString("AbdulWahid");
						   //DataEncryptor.Instance.GetDecryptedString(str);
            
						   IUser user = userLogin.AuthenticateUser(txtLogin.Text, txtPassword.Text);
						   if (user != null)
						   {
							   //authentication succeeded.
							   UserProfile.Instance.User = user;
							   FormsAuthenticationTicket ticket =
								   new FormsAuthenticationTicket(user.UserId, isPersistent, 20);
                
							   // Encrypt the ticket.
							   string encTicket = FormsAuthentication.Encrypt(ticket);

							   // Create the cookie.
							   Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

							   // Redirect back to original URL.
							   Response.Redirect(FormsAuthentication.GetRedirectUrl(user.UserId, isPersistent));


						   }
						   else
						   {
							   lblErrorMessage.Text= ResourceProvider.GetGeneralResourceString("Message_LoginFailed");
							   //authentication failed.
						   }
           
					   }
				   }


<!--##/session##-->
#endregion



